import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;


public class ClearScreen extends JPanel implements MouseListener {

//	private Clip bgm;
	private Image endingImage;
	
	public ClearScreen(){
//		try{
//		bgm = AudioSystem.getClip();
//		bgm.open(Constants.ending);
//		bgm.loop(Clip.LOOP_CONTINUOUSLY);
//		}catch(Exception ex){ex.printStackTrace();}
		init();
	}
	
	
	public void paint(Graphics g) {
	
		super.paint(g);
		g.drawImage(endingImage, 0, 0, null);
	}
	private void init() {
		
		try{
			URL url = getClass().getResource("ending.jpg");
			Image orignalImage = ImageIO.read(url); 
			endingImage = orignalImage.getScaledInstance(Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT, Image.SCALE_SMOOTH);
		}catch(Exception ex){ex.printStackTrace();}
		setLayout(null);
		setSize(Constants.SCREEN_WIDTH,Constants.SCREEN_HEIGHT);
		
		addMouseListener(this);
		validate();
		repaint();
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		JOptionPane.showMessageDialog(getParent(), "축하합니다! 클리어 하셨습니다");
		MainPanel open = new MainPanel();
		Container frame = getParent();
		frame.add(open);
		frame.remove(this);
		frame.validate();
		frame.repaint();
	}
	@Override
	public void mouseEntered(MouseEvent e) {	
	}
	@Override
	public void mouseExited(MouseEvent e) {
	}
	@Override
	public void mousePressed(MouseEvent e) {
	}
	@Override
	public void mouseReleased(MouseEvent e) {		
	}
	
	

}

